//
//  HomeListCell.m
//  EasyToTesco2.0
//
//  Created by 杨森 on 2017/5/18.
//  Copyright © 2017年 EasyToTesco. All rights reserved.
//

#import "HomeListCell.h"

@interface HomeListCell()

@property(nonatomic,strong)UIImageView  *mainImg;

@property(nonatomic,strong)UIView       *conView;
@property(nonatomic,strong)UIImageView  *tagImg;
@property(nonatomic,strong)UILabel      *titleLabel;
@property(nonatomic,strong)UILabel      *detailsLabel;
@property(nonatomic,strong)UIView       *lineView;

@property(nonatomic,strong)UILabel      *priceLabel;
@property(nonatomic,strong)UILabel      *dateLabel;

@end

@implementation HomeListCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self buildView];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)buildView
{
    [self.contentView addSubview:self.mainImg];
    [self.contentView addSubview:self.conView];
    [self.conView addSubview:self.titleLabel];
    [self.conView addSubview:self.tagImg];
    [self.conView addSubview:self.detailsLabel];
    [self.conView addSubview:self.lineView];
    
    [self.contentView addSubview:self.priceLabel];
    [self.contentView addSubview:self.dateLabel];
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.mainImg.frame = CGRectMake(0,0,self.width,self.Height*0.75-5);
    self.conView.frame = CGRectMake(0,CGRectGetMaxY(_mainImg.frame), self.width,self.Height-_mainImg.Height);
    
    WeakSelf(self);
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakself.mas_left).offset(15);
        make.top.equalTo(weakself.conView.mas_top).offset(5);
    }];
    
    [self.tagImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakself.mas_left).offset(15);
        make.top.equalTo(weakself.titleLabel.mas_bottom).offset(3);
        make.width.mas_equalTo(35);
        make.height.mas_equalTo(15);
    }];
    
    [self.detailsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakself.tagImg.mas_right).offset(3);
        make.centerY.equalTo(weakself.tagImg);
        make.width.mas_equalTo(self.width - 78);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(weakself.conView.mas_bottom);
        make.width.mas_equalTo(self.width);
        make.height.mas_equalTo(5);
    }];
    
    
    [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakself.mas_top).offset(self.Height*0.45);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(60);
        make.right.equalTo(weakself.mas_right).offset(-15);
    }];
    
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakself.priceLabel.mas_bottom);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(60);
        make.right.equalTo(weakself.mas_right).offset(-15);
    }];
    
}


#pragma mark lazy
-(UIImageView *)mainImg
{
    if (!_mainImg) {
        _mainImg = [[UIImageView alloc] init];
        _mainImg.image = [UIImage imageNamed:@"home_ranking_bg"];
    }
    return _mainImg;
}

- (UIView *)conView
{
    if (!_conView) {
        _conView = [[UIView alloc] init];
    }
    return _conView;
}

- (UIImageView *)tagImg
{
    if (!_tagImg) {
        _tagImg = [[UIImageView alloc] init];
        _tagImg.image = [UIImage imageNamed:@"home_ranking_tag"];
    }
    return _tagImg;

}

- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.text = @"万里长城 + 布达拉宫 + 杭州四季青";
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.font = FONT(13);
    }
    return _titleLabel;
}

- (UILabel *)detailsLabel
{
    if (!_detailsLabel) {
        _detailsLabel = [[UILabel alloc] init];
        _detailsLabel.textColor = [UIColor grayColor];
        _detailsLabel.font = FONT(12);
        _detailsLabel.text = @"体验不同的名宿风情,给十年后的自己一个摸摸哒";
        _detailsLabel.textAlignment = NSTextAlignmentLeft;
    }
    return _detailsLabel;
}


- (UIView *)lineView
{
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = [UIColor lightGrayColor];
        _lineView.alpha= 0.2f;
    }
    return _lineView;
}

- (UILabel *)priceLabel
{
    if (!_priceLabel) {
        _priceLabel = [[UILabel alloc] init];
        _priceLabel.textColor = [UIColor whiteColor];
        _priceLabel.backgroundColor = DEFAULT_COLOR;
        _priceLabel.font = FONT(11);
        _priceLabel.text = @"1000元起";
        _priceLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _priceLabel;
}

- (UILabel *)dateLabel
{
    if (!_dateLabel) {
        _dateLabel = [[UILabel alloc] init];
        _dateLabel.backgroundColor = [UIColor whiteColor];
        _dateLabel.font = FONT(11);
        _dateLabel.text = @"8日游";
        _dateLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _dateLabel;
}



@end
